package com.appinterfacelite.controller;

import com.appinterfacelite.service.InterfaceService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 解决跨域问题而封装的接口控制层
 */
@Controller
@RequestMapping("/interface")
public class InterfaceController {
    @Autowired
    InterfaceService interfaceService;

    @GetMapping("/channelList")
    @ResponseBody
    public JSONObject channelList(String https,
                                  String parentId,
                                  String siteId,
                                  Boolean hasContentOnly,
                                  String first,
                                  String count) {
        return interfaceService.channelList(https, parentId, siteId, hasContentOnly, first, count);
    }

    @GetMapping("contentList")
    @ResponseBody
    public JSONObject contentList(
            String format, String https, String ids, String tagIds, String channelIds,
            String siteIds, String typeIds, String titleImg, String recommend, String orderBy,
            String title, String channelOption, String first, String count
    ) {
        return interfaceService.contentList(format, https, ids, tagIds, channelIds, siteIds, typeIds, titleImg, recommend, orderBy, title, channelOption, first, count);
    }

    @GetMapping("/contentGet")
    @ResponseBody
    public JSONObject contentGet(
            String format, String https, String sessionKey, String appId, String id, String next, String channelId, String siteId
    ) {
        return interfaceService.contentGet(format, https, sessionKey, appId, id, next, channelId, siteId);
    }

//    @GetMapping("/test")
//    @ResponseBody
//    public JSONObject test(){
//        return interfaceService.test();
//    }
}
